using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Admin;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
public class HL_Admin_Admin_ShopComplain : Admin, IRequiresSessionState
{
	private Shop_Complain _complain;
	private string m_type = "";
	private string m_status = "";
	private string m_time = "";
	private int m_salerid = 0;
	protected bool m_tag = false;
	protected string WhereStr = "";
	protected string OrderByStr = "";
	protected string LinkHead = "";
	private static int ComplainID = 0;
	protected DropDownList DropType1;
	protected DropDownList DropStatus1;
	protected DropDownList DropStartTime1;
	protected TextBox salername;
	protected DropDownList DropDownList1;
	protected Panel sreachbar;
	protected GridView GridView2;
	protected Label PagePanel;
	protected TextBox TextBox1;
	protected Button Button1;
	protected RequiredFieldValidator rv;
	protected Panel Panel1;
	protected Shop_Complain m_complain
	{
		get
		{
			Shop_Complain complain;
			if (this._complain == null)
			{
				this._complain = new Shop_Complain(this.conn);
				complain = this._complain;
			}
			else
			{
				complain = this._complain;
			}
			return complain;
		}
	}
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.admin.CheckAdminPower(23))
		{
			base.WriteLog("View", Language.GetAdminMsg("Log/Access", "0"), "Complain");
			base.WriteRightErrMsg();
		}
		this.BindUserList();
		if (!base.IsPostBack)
		{
			HL_Admin_Admin_ShopComplain.ComplainID = Fetch.GetID("ReviewComplainID");
			if (HL_Admin_Admin_ShopComplain.ComplainID != 0)
			{
				DataTable complainByComplainID = this.m_complain.GetComplainByComplainID(HL_Admin_Admin_ShopComplain.ComplainID);
				string text = "";
				if (complainByComplainID.Rows.Count > 0)
				{
					text = complainByComplainID.Rows[0]["Result"].ToString();
				}
				this.TextBox1.Text = text;
				this.GridView2.Visible = false;
				this.Panel1.Visible = true;
				this.DropType1.Enabled = false;
				this.DropStatus1.Enabled = false;
				this.DropStartTime1.Enabled = false;
				this.salername.Enabled = false;
				this.DropDownList1.Enabled = false;
				this.PagePanel.Enabled = false;
			}
			else
			{
				this.ShowList();
			}
			this.BindList();
		}
	}
	protected void BindUserList()
	{
		if (this.salername.Text != "")
		{
			UserBll userBll = new UserBll(this.conn);
			int userIDByUserName = userBll.GetUserIDByUserName(this.salername.Text.Trim());
			if (userIDByUserName > 0)
			{
				foreach (ListItem listItem in this.DropDownList1.Items)
				{
					if (listItem.Value == userIDByUserName.ToString())
					{
						this.salername.Text = "";
						return;
					}
				}
				this.DropDownList1.Items.Add(new ListItem(this.salername.Text, userIDByUserName.ToString()));
				this.DropDownList1.SelectedValue = userIDByUserName.ToString();
			}
			this.salername.Text = "";
		}
	}
	protected void BindList()
	{
		int num = Fetch.GetID("page");
		if (num <= 0)
		{
			num = 1;
		}
		this.QuestString();
		int maxperpage = 15;
		if (this.GridView2.PageSize > 0)
		{
			maxperpage = int.Parse(this.GridView2.PageSize.ToString());
		}
		this.GridView2.DataSource = this.m_complain.GetAllComplains(num, maxperpage, this.WhereStr, this.OrderByStr);
		this.GridView2.DataBind();
		this.PagePanel.Text = this.m_complain.GetPagePanel(this.LinkHead);
	}
	protected void QuestString()
	{
		this.m_type = Fetch.Get("type");
		if (this.m_type != string.Empty && this.m_tag)
		{
			this.DropType1.SelectedValue = this.m_type;
		}
		else
		{
			this.m_type = this.DropType1.SelectedValue;
		}
		if (this.m_type != "-1")
		{
			if (this.m_type == "0")
			{
				this.WhereStr += "and ComplainType='投诉' ";
			}
			else
			{
				if (this.m_type == "1")
				{
					this.WhereStr += "and ComplainType='举报' ";
				}
			}
			this.LinkHead = this.LinkHead + "&type=" + this.m_type;
		}
		this.m_status = Fetch.Get("status");
		if (this.m_status != string.Empty && this.m_tag)
		{
			this.DropStatus1.SelectedValue = this.m_status;
		}
		else
		{
			this.m_status = this.DropStatus1.SelectedValue;
		}
		if (this.m_status != "-1")
		{
			if (this.m_status == "0")
			{
				this.WhereStr += "and Status=0 ";
			}
			else
			{
				if (this.m_status == "1")
				{
					this.WhereStr += "and Status=1 ";
				}
			}
			this.LinkHead = this.LinkHead + "&status=" + this.m_status;
		}
		this.m_time = Fetch.Get("time");
		if (this.m_time != string.Empty && this.m_tag)
		{
			this.DropStartTime1.SelectedValue = this.m_time;
		}
		else
		{
			this.m_time = this.DropStartTime1.SelectedValue;
		}
		if (this.m_time == "0")
		{
			this.WhereStr += "and DATEDIFF(month,StartTime,getdate())=0 ";
			this.LinkHead = this.LinkHead + "&status=" + this.m_status;
		}
		else
		{
			if (this.m_time == "1")
			{
				this.WhereStr += "and DATEDIFF(month,StartTime,getdate())>1 ";
				this.LinkHead = this.LinkHead + "&status=" + this.m_status;
			}
		}
		this.m_salerid = Fetch.GetID("salerid");
		if (this.m_salerid != 0 && this.m_tag)
		{
			this.DropDownList1.SelectedValue = this.m_salerid.ToString();
		}
		else
		{
			this.m_salerid = Convert.ToInt32(this.DropDownList1.SelectedValue);
			if (this.salername.Text != "")
			{
				this.WhereStr += "and UserID=0 ";
			}
			else
			{
				if (this.m_salerid != 0)
				{
					object whereStr = this.WhereStr;
					this.WhereStr = string.Concat(new object[]
					{
						whereStr,
						"and UserID=",
						this.m_salerid,
						" "
					});
					this.LinkHead = this.LinkHead + "&salerid=" + this.m_status;
				}
			}
		}
		if (this.WhereStr != "")
		{
			this.WhereStr = "and" + this.WhereStr;
			this.WhereStr = this.WhereStr.Replace("andand", "where");
		}
	}
	protected void GridView2_DataBound(object sender, EventArgs e)
	{
		foreach (GridViewRow gridViewRow in this.GridView2.Rows)
		{
			Label label = (Label)gridViewRow.FindControl("Label3");
			Label label2 = (Label)gridViewRow.FindControl("Label4");
			Label label3 = (Label)gridViewRow.FindControl("Label5");
			Label label4 = (Label)gridViewRow.FindControl("Label6");
			label3.Attributes.Add("onMouseOver", string.Concat(new string[]
			{
				"SetNewColor(getElementById('",
				label.ClientID,
				"'),getElementById('",
				label3.ClientID,
				"'));"
			}));
			label3.Attributes.Add("onMouseOut", string.Concat(new string[]
			{
				"SetOldColor(getElementById('",
				label.ClientID,
				"'),getElementById('",
				label3.ClientID,
				"'));"
			}));
			label4.Attributes.Add("onMouseOver", string.Concat(new string[]
			{
				"SetNewColor1(getElementById('",
				label2.ClientID,
				"'),getElementById('",
				label4.ClientID,
				"'));"
			}));
			label4.Attributes.Add("onMouseOut", string.Concat(new string[]
			{
				"SetOldColor1(getElementById('",
				label2.ClientID,
				"'),getElementById('",
				label4.ClientID,
				"'));"
			}));
		}
	}
	protected void Button1_Click(object sender, EventArgs e)
	{
		if (!base.admin.CheckAdminPower(23))
		{
			base.WriteRightErrMsg();
		}
		if (this.m_complain.UpdateComplain(HL_Admin_Admin_ShopComplain.ComplainID, this.TextBox1.Text))
		{
			this.WriteSuccessMsg("", Language.GetAdminMsg("Review/ResultUpdate"), "Admin_ShopComplain.aspx");
		}
	}
	protected void DropType1_Change(object sender, EventArgs e)
	{
		this.ShowList();
		this.m_tag = false;
		this.BindList();
	}
	protected void DropStatus1_Change(object sender, EventArgs e)
	{
		this.ShowList();
		this.m_tag = false;
		this.BindList();
	}
	protected void DropStartTime1_Change(object sender, EventArgs e)
	{
		this.ShowList();
		this.m_tag = false;
		this.BindList();
	}
	protected void salername_Change(object sender, EventArgs e)
	{
		this.ShowList();
		this.m_tag = false;
		this.BindList();
	}
	protected void DropDownList1_Change(object sender, EventArgs e)
	{
		this.ShowList();
		this.m_tag = false;
		this.BindList();
	}
	protected void ShowList()
	{
		this.Panel1.Visible = false;
		this.GridView2.Visible = true;
		this.DropType1.Enabled = true;
		this.DropStatus1.Enabled = true;
		this.DropStartTime1.Enabled = true;
		this.salername.Enabled = true;
		this.DropDownList1.Enabled = true;
		this.PagePanel.Enabled = true;
	}
	protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		if (e.Row.RowType == DataControlRowType.DataRow)
		{
			e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#E7EDFE'");
			e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
		}
	}
	protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
	{
		this.m_complain.DeleteComplain(int.Parse(this.GridView2.SelectedRow.Cells[0].Text));
		this.m_tag = false;
		this.BindList();
	}
}
